/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.nju.zyy.basic.daemon;

import java.util.concurrent.TimeUnit;


/**
 *
 * @author yingyzhang
 */
class ADaemon implements Runnable {

    @Override
    public void run() {
        try {
            System.out.println("Starting ADaemon");
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            System.out.println("Exiting via InterruptedException");
        } finally {
            System.out.println("This should always run?");
        }
    }
    
}

public class DaemonsDontRunFinally {
    
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(new ADaemon());
        t.setDaemon(true);
        t.start();
        // Allow the daemon thread to finish its startup process.
        TimeUnit.MICROSECONDS.sleep(100);
    }
}
